
package com.bluelinelabs.conductor.demo.controllers;

import ohos.aafwk.content.IntentParams;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Component;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;

import com.bluelinelabs.conductor.demo.ResourceTable;
import com.bluelinelabs.conductor.demo.controllers.base.BaseController;

/**
 * lipeiquan
 *
 * @since 2021-05-06
 */
public class ChildController extends BaseController {
    private IntentParams args;
    public static final String KEY_TITLE = "ChildController.title";
    public static final String KEY_BG_COLOR = "ChildController.bgColor";
    public static final String KEY_COLOR_IS_RES = "ChildController.colorIsResId";
    private String backgroundColor;

    public ChildController(IntentParams args) {
        super(ResourceTable.Layout_controller_child, args);
        this.args = args;
        backgroundColor = (String) args.getParam(KEY_BG_COLOR);
    }

    @Override
    public void onViewCreated(Component component) {
        Text Id_title = (Text) component.findComponentById(ResourceTable.Id_title);
        Id_title.setText((String) args.getParam(KEY_TITLE));
        ShapeElement shapeElement;
        shapeElement = new ShapeElement();
        shapeElement.setRgbColor(RgbColor.fromArgbInt(Color.getIntColor(backgroundColor)));
        component.setBackground(shapeElement);
    }


}
